﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using WebComponents;
using WebComponents.Data;

public partial class san_pham : System.Web.UI.Page {
  protected void Page_Load(object sender, EventArgs e) {
    int id = ConvertType.ToInt(Request.Params["cid"]);
    lblTitle.Text = "<a href=\"san-pham-.aspx\" class=\"link_path\">Sản phẩm</a>";
    if (id > 0) {
      CategoryInfo cate = CategoryController.GetByCategoryID(id);
      if (cate != null) {
        if (cate.ParentID == 0) {
          lblTitle.Text += " > " + string.Format("<a href=\"{0}san-pham/{1}/{2}-.aspx\" class=\"link_path\">{3}</a>", Page.ResolveClientUrl("~/"), cate.CategoryID, ConvertType.StripDiacritics(cate.NameVi), cate.NameVi);
          this.Title = cate.NameVi;
        } else {
          CategoryInfo parent1 = CategoryController.GetByCategoryID(cate.ParentID);
          CategoryInfo parent2 = null;
          CategoryInfo parent3 = null;
          if (parent1 != null && parent1.ParentID > 0) {
            parent2 = CategoryController.GetByCategoryID(parent1.ParentID);
            if (parent2 != null && parent2.ParentID > 0) {
              parent3 = CategoryController.GetByCategoryID(parent2.ParentID);
            }
          }
          if (parent3 != null) {
            lblTitle.Text += " > " + string.Format("<a href=\"{0}san-pham/{1}/{2}-.aspx\" class=\"link_path\">{3}</a>", Page.ResolveClientUrl("~/"), parent3.CategoryID, ConvertType.StripDiacritics(parent3.NameVi), parent3.NameVi);
          }
          if (parent2 != null) {
            lblTitle.Text += " > " + string.Format("<a href=\"{0}san-pham/{1}/{2}-.aspx\" class=\"link_path\">{3}</a>", Page.ResolveClientUrl("~/"), parent2.CategoryID, ConvertType.StripDiacritics(parent2.NameVi), parent2.NameVi);
          }
          if (parent1 != null) {
            lblTitle.Text += " > " + string.Format("<a href=\"{0}san-pham/{1}/{2}-.aspx\" class=\"link_path\">{3}</a>", Page.ResolveClientUrl("~/"), parent1.CategoryID, ConvertType.StripDiacritics(parent1.NameVi), parent1.NameVi);
          }
          lblTitle.Text += " > " + string.Format("<a href=\"{0}san-pham/{1}/{2}-.aspx\" class=\"link_path\">{3}</a>", Page.ResolveClientUrl("~/"), cate.CategoryID, ConvertType.StripDiacritics(cate.NameVi), cate.NameVi);
          this.Title = cate.NameVi;
        }
      }
    }
  }
}
